﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />

var canEditRestriction = true;
myapp.ViewRestriction.ShowAddEditRestriction_Tap_canExecute = function (screen) {
    return canEditRestriction;
};
myapp.ViewRestriction.ShowAddEditRestriction_Tap_execute = function (screen) {
    this.myapp.showAddEditRestriction(screen.Restriction);
};

myapp.ViewRestriction.Details_postRender = function (element, contentItem) {
    contentItem.dataBind("screen.Place.Id", function (newValue) {
        contentItem.screen.details.displayName = "Place (" + (newValue == null ? "New" : newValue) + ")";
    });
    /*$.ajax({
        type: 'post',
        data: {},
        url: '../web/UserCanEditRestrictions....ashx',
        success: function success(result) {
            canEditPlace = result;
        }
    });*/
};
myapp.ViewRestriction.DeepLink_postRender = function (element, contentItem) {
    var hashPos = window.location.href.indexOf("#");
    if (hashPos >= 0)
        var baseUrl = window.location.href.substr(0, hashPos);
    else
        var baseUrl = window.location.href;
    var fullUrl = baseUrl + "?entity=MMC_Content/Restrictions(" +
                  contentItem.screen.Place.Id + ")";
    contentItem.screen.RestrictionUrl = fullUrl;
};